package com.yjt.fresh.activity;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.wzgiceman.rxretrofitlibrary.retrofit_rx.http.HttpManager;
import com.wzgiceman.rxretrofitlibrary.retrofit_rx.listener.HttpOnNextListener;
import com.yjt.fresh.R;
import com.yjt.fresh.adpater.AdpRvAtyTalkDetail;
import com.yjt.fresh.api.ApiGetConsultRecords;
import com.yjt.fresh.base.BaseSimpleActivity;
import com.yjt.fresh.bean.BeanTalkDetail;
import com.yjt.fresh.constant.MyConstants;
import com.yjt.fresh.utils.PreferenceManager;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2018-09-07.
 */

public class AtyTalkDetail extends BaseSimpleActivity {
    @BindView(R.id.back)
    RelativeLayout mBack;
    @BindView(R.id.rvAppAtyTalkDetail)
    RecyclerView mRv;
    private AdpRvAtyTalkDetail mAdpRvAtyTalkDetail;


    @Override
    protected int getContentView() {
        return R.layout.app_aty_talk_detail;
    }

    @Override
    protected void initViews() {
        ButterKnife.bind(this);
    }

    @Override
    protected void initEvent() {
        initRV();
        getData();
        initClick();
    }

    private void initClick() {
        mBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

    private void getData() {
        ApiGetConsultRecords apiGetConsultRecords = new ApiGetConsultRecords(new HttpOnNextListener<List<BeanTalkDetail>>() {
            @Override
            public void onNext(List<BeanTalkDetail> beanTalkDetails) {
                mAdpRvAtyTalkDetail.setNewData(beanTalkDetails);
            }

            @Override
            public void onReLogin() {

            }
        },mContext,true,false,false);
        Map<String,Object> map = new HashMap<>();
        map.put("BACKORDER_ID",getIntent().getStringExtra(MyConstants.ORDER_ID));
        map.put("SESSION_ID", PreferenceManager.getInstance().getUserInfo().getSESSION_ID());
        apiGetConsultRecords.setMap(map);
        HttpManager.getInstance().doHttpDeal(apiGetConsultRecords);
    }

    private void initRV() {
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(mContext);
        mRv.setLayoutManager(linearLayoutManager);
        List<BeanTalkDetail> list = new ArrayList<>();
        mAdpRvAtyTalkDetail = new AdpRvAtyTalkDetail(R.layout.app_recycle_item_talk_detail, list);
        mRv.setAdapter(mAdpRvAtyTalkDetail);
    }

}
